<style lang="less">
    @import './login.less';
</style>

<template>
    <div class="login">
        <div class="login-con">
            <Card icon="log-in" title="欢迎登录" :bordered="false">
                <div class="form-con">
                    <login-form @on-success-valid="handleSubmit"></login-form>
                </div>
            </Card>
        </div>
    </div>
</template>

<script>
  import LoginForm from '_c/login-form'
  import Core from 'core/core'

  export default {
    components: {
      LoginForm
    },
    data () {
      return {
        captchaValid: false,
      }
    },
    methods: {
      handleSubmit ({ userName, password }) {
        Core.Api.Admin.login({
          username: userName,
          password: password
        }).then(res => {
          Core.Data.setToken(res.token)
          Core.Data.setUser(res.admin)
          this.$router.push('/home')
        }).catch(err => {
            console.error(err)
        })
      }
    }
  }
</script>

<style>

</style>
